<?php
class Sss_Ultility_MonitoringLocalizationFuction {
	function updateChartRes($arrTable,$presetChartid,$userInformation,$params,$updatedPreset,$chartId,$graphId)
	{
		$defaultOvisNamespace = new Zend_Session_Namespace(Sss_Ultility_SessionName::OVIS_SHEPHERD_SYSTEM . $handle);
		$instanceId = $defaultOvisNamespace->dbShepherd;
		$presetTable = $arrTable['presetTable'];
		$presetChartTable = $arrTable['presetChartTable'];
		$presetGraphTable = $arrTable['presetGraphTable'];
		$chartTable = $arrTable['chartTable'];
		$graphTable = $arrTable['graphTable'];
		if($presetChartid != 0) {
			//update Preset Name
			$presetUpdate = $presetTable->findById((int) $updatedPreset->presetid);
			$presetUpdate->setPresetName(addslashes($params['txtPresetName']));
			$updatedPresetRes = $presetTable->save($presetUpdate,$instanceId);
			//Update Preset Chart
			$chartUpdate = $presetChartTable->findById((int) $chartId);
			$chartUpdate->setChartName(addslashes($params['txtChartName']));
			$updatedChartRes = $presetChartTable->save($chartUpdate,$instanceId);
			//Update preset graphs
			$graphUpdate = $presetGraphTable->findById($graphId);
			$graphUpdate->setGraphName(addslashes($params['txtGraphName']));
			$graphUpdate->setColor($params['hdColor']);
			$updatedChartRes = $presetGraphTable->save($graphUpdate,$instanceId);
		} else { 
			//Update Chart
			$chartUpdate = $chartTable->findById((int) $chartId);
			$chartUpdate->setChartName(addslashes($params['txtChartName']));
			$chartUpdate->setUpdatedDate(strtotime('now'));
			$chartUpdate->setUpdatedBy($userInformation->accountid);
			$chartUpdate->setNotes($params['txtNotes']);
			$updatedChartRes = $chartTable->save($chartUpdate,$instanceId);
			//Update Graph
			$graphUpdate = $graphTable->findById($graphId);
			$graphUpdate->setGraphName($params['txtGraphName']);
			$graphUpdate->setColor($params['hdColor']);
			$updatedChartRes = $graphTable->save($graphUpdate,$instanceId);
		}
	}
}